package _06_动态规划;

public class _509_斐波那契数 {

    // 递归超时，存在太多的重复子问题计算
    public int fib(int n) {
        if (n <= 1) return n;
        int first = 0;
        int second = 1;
        for (int i = 2; i <= n; i++) {
            second = first + second;
            first = second - first;
        }
        return second;
    }

}
